function $(d){
	return document.getElementById(d);
}

function dsp(d,v){
	if(v==undefined){
		return d.style.display;
	}else{
		d.style.display=v;
	}
}

function sh(d,v){
	if(v==undefined){
		if(dsp(d)!='none'&& dsp(d)!=''){
			return d.offsetHeight;
		}
		viz = d.style.visibility;
		d.style.visibility = 'hidden';
		o = dsp(d);
		dsp(d,'block');
		r = parseInt(d.offsetHeight);
		dsp(d,o);
		d.style.visibility = viz;
		return r;
	}else{
		d.style.height=v;
	}
}

s=7;
t=10;

function ct(d){
	d = $(d);
	if(sh(d)>0){
		v = Math.round(sh(d)/d.s);
		v = (v<1) ? 1 :v ;
		v = (sh(d)-v);
		sh(d,v+'px');
		d.style.opacity = (v/d.maxh);
		d.style.filter= 'alpha(opacity='+(v*100/d.maxh)+');';
	}else{
		sh(d,0);
		dsp(d,'none');
		clearInterval(d.t);
	}
}

function et(d){
	d = $(d);

	if(sh(d)<d.maxh){
		v = Math.round((d.maxh-sh(d))/d.s);
		v = (v<1) ? 1 :v ;
		v = (sh(d)+v);
		sh(d,v+'px');
		d.style.opacity = (v/d.maxh);
		d.style.filter= 'alpha(opacity='+(v*100/d.maxh)+');';

	}else{
		sh(d,d.maxh);
		clearInterval(d.t);
		newStr=d.id.replace(/content/,"header");

		if(navigator.userAgent.indexOf("NetFront") != -1){
			obj = document.getElementById(newStr); 
			y = obj.offsetTop;
			scrollTo(0,y-52);
		}else{
			location.href="#"+newStr;
		}

	}
}


function cl(d){
	if(dsp(d)=='block'){
		clearInterval(d.t);
		d.t=setInterval('ct("'+d.id+'")',t);
	}
}


function ex(d){

if(dsp(d)=='none'){
		dsp(d,'block');
		d.style.height='0px';
		clearInterval(d.t);
		d.t=setInterval('et("'+d.id+'")',t);
	}
}

function cc(n,v){
	s=n.className.split(/\s+/);
	for(p=0;p<s.length;p++){
		if(s[p]==v+n.tc){
			s.splice(p,1);
			n.className=s.join(' ');
			break;
		}
	}
}

function Accordian(d,s,tc){

	l=$(d).getElementsByTagName('div');
	c=[];
	for(i=0;i<l.length;i++){
		h=l[i].id;
		if(h.substr(h.indexOf('-')+1,h.length)=='content'){c.push(h);}
	}
	sel=null;

	
	for(i=0;i<l.length;i++){
		h=l[i].id;

		if(h.substr(0,6)=='single'){
			singleID=$(h);
			singleID.onclick = function(){
				WriteCookie("accOpen", this.id, 0);
			}
		}
		if(h.substr(h.indexOf('-')+1,h.length)=='header'){
			d=$(h.substr(0,h.indexOf('-'))+'-content');
			d.style.display='none';
			d.style.overflow='hidden';
			d.maxh =sh(d);
			d.s=(s==undefined)? 7 : s;
			h=$(h);
			h.tc=tc;
			h.c=c;

			var onFlag = ""

			h.onclick = function(){
				var headerHighlight = this.className.indexOf("header_highlight",0);
				if(headerHighlight==null){
					headerHighlight = this.getAttribute("className").indexOf("header_highlight",0);
				}
				WriteCookie("accOpen", this.id, 0);

				for(i=0;i<this.c.length;i++){
					cn=this.c[i];
					n=cn.substr(0,cn.indexOf('-'));

					if((n+'-header')==this.id){
						if(headerHighlight==-1&&onFlag==""){
							onFlag="on"
						}
						if(headerHighlight!=-1&&onFlag=="on"){
							cl($(n+'-content'));
							cc($(n+'-header'),'');
							onFlag=""						
						}
						if(headerHighlight==-1&&onFlag=="on"){
							cc($(n+'-header'),'');
							ex($(n+'-content'),$(n+'-header'));

							n=$(n+'-header');
							cc(n,'__');
							n.className=n.className+' '+n.tc;
							onFlag="on"
						}
					}else{
						cl($(n+'-content'));
						cc($(n+'-header'),'');
						$(n+'-content').style.height=0;
					}

				}
			}
			if(h.className.match(/selected+/)!=undefined){ sel=h;}
		}
	}
	if(sel!=undefined){sel.onclick();}
	if(location.hash!=""){
		var openTab=location.hash;
		if(openTab.substr(0,7)=='#single'){
			location.href=openTab;
		}else{
			openTab = openTab.replace("#","");
			openTab = openTab.replace("-header","");
			ex($(openTab+'-content'));
			n=$(openTab+'-header');
			cc(n,'__');
			n.className=n.className+' '+n.tc;
			location.href="#"+openTab+"-header";
			onFlag="on"
		}
	}
}


function smartRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");
		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("src").match("_off."))
			{
				images[i].onmouseover = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));
				}
				images[i].onmouseout = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));
				}
			}
		}
	}
}
if(window.addEventListener) {
	window.addEventListener("load", smartRollover, false);
}
else if(window.attachEvent) {
	window.attachEvent("onload", smartRollover);
}


function resizeWinodow(){
	$$('.contentsArea').setStyle("display","block");
	var browserHeight = document.documentElement.clientHeight;
	var contentsHeight = browserHeight - ($('header').offsetHeight) - ($('logo').offsetHeight) - ($('menuFooter').offsetHeight) + "px"
	var leftrightHeight = browserHeight - ($('logo').offsetHeight)
	
	if(browserHeight>160){
		$$('.contentsArea').setStyle("height",contentsHeight);
		if(navigator.userAgent.indexOf("MSIE") != -1){ 
			$('leftcolumn').style.height = leftrightHeight;
			$('rightcolumn').style.height = leftrightHeight;
		}else{
			$('leftcolumn').setStyle("height",leftrightHeight);
			$('rightcolumn').setStyle("height",leftrightHeight);
		}
	}
}

function resizeBotttom(){
	if($("accordionBottom").offsetHeight!="0px"){
		$("accordionBottom").style.height="0px";
	}
	$("debug").innerHTML = $("accordionBottom").offsetHeight
}


function WriteCookie(key, value, days) {
     var str = key + "=" + escape(value) + ";"; 
     if (days != 0) {
          var dt = new Date();
          dt.setDate(dt.getDate() + days);
          str += "expires=" + dt.toGMTString() + ";";
     }
     document.cookie = str;
}

window.onload = function(){
	if(navigator.userAgent.indexOf("NetFront") != -1){
		
	}else{
		new Accordian('accordion',1,'header_highlight');
		resizeWinodow();
	}
}

window.onresize = function(){
	if(navigator.userAgent.indexOf("NetFront") != -1){
		
	}else{
		resizeWinodow();
	}
}

if(navigator.userAgent.indexOf("NetFront") != -1){
	css1 = "../styles_nf/menu.css";
}else{
	css1 = "../styles/menu.css";
}
var css = '<';	css+='link rel="stylesheet" href=' + css1 + ' \/';	css+='>';
document.write(css);

